from PyQt4 import QtCore , QtGui
from lib.customUI import customUI
from lib.papyDB import papyDB , tableInfo
from lib.papyDBTable import *

class insertItemDiag_UI( QtGui.QDialog,customUI ):
    def __init__(self , parent=None):
        QtGui.QDialog.__init__(self,parent)
        customUI.__init__(self)        
        self.setWindowTitle( "Select Items" )
        self.setObjectName('insertItem')
        self.parent = parent
        
    def createAssetTable(self):        
        self.setStyleSheet(self.styleSheet)        
        headerList = ['id','Asset' , 'Status' , 'Type' , 'Rigging' , 'Texture' , 'Description']
        self.asset_table = QtGui.QTableView( self )
        self.asset_table.setSizePolicy( self.sizePolicy_exex )
        self.asset_table.setMinimumHeight(250)
        self.asset_table.setGridStyle(QtCore.Qt.DashLine)
        self.asset_table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.asset_table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.asset_table.setAlternatingRowColors(True)
        self.asset_table.setFont( self.mainFont )
        
    def createTagLine(self):
        self.tag_lineEdt = self.lineEdt()
        self.tag_lineEdt.setFont( self.KORFont )
        self.tagSearch_btn = self.btn('Search')
        self.tagSearch_btn.setMaximumWidth(100)      
        
        tag_lb = self.label("Tags")
        self.tag_layout = QtGui.QHBoxLayout()
        self.tag_layout.addWidget(tag_lb)
        self.tag_layout.addWidget(self.tag_lineEdt)
        self.tag_layout.addWidget(self.tagSearch_btn)
        
    def createInsertItemBtn(self):
        self.insertItem_btn = self.btn("Insert Item")
        self.insertItem_btn.setMinimumHeight(40)
            
    def setUI(self):
#        self.mainWidget = QtGui.QWidget(  )
        self.createPSSDcb()
        self.createTagLine()  
        self.createAssetTable()
        self.createInsertItemBtn()  
        spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                    QtGui.QSizePolicy.Fixed) 
        
        childGridLayout = QtGui.QGridLayout( self )
#        childGridLayout = QtGui.QGridLayout( self.mainWidget )
        childGridLayout.addLayout( self.PSSD_layout , 0, 0, 1, 1 )
        childGridLayout.addItem( spacer , 0, 1, 1, 1)
        childGridLayout.addLayout( self.tag_layout , 1, 0, 1, 1 )
        childGridLayout.addWidget( self.asset_table , 2, 0, 1, 2 )
        childGridLayout.addWidget( self.insertItem_btn , 3, 0, 1, 2 )  
##        self.setCentralWidget( self.mainWidget )
        
        if self.parent != None:
            pos = self.parent.pos()
            self.move( pos.x() +700 , pos.y()+30 )                   
#            self.setGeometry( QtCore.QRect( pos.x() +660, pos.y()+30,260,200 ) )
        else :            
            pos = QtGui.QCursor()            
            self.setGeometry( QtCore.QRect( pos.pos().x(), pos.pos().y()+20,260,200 ) )        
        self.show()        
#        self.adjustSize()
        
        
        
if __name__ == '__main__':
    import sys    
    app = QtGui.QApplication(sys.argv)
    ui = insertItemDiag_UI()
    ui.setUI()
    app.exec_()        